package com.xkdx.caipiao.presistence.quert;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xkdx.caipiao.module.network.AbsModule;
import com.xkdx.caipiao.presistence.hongbao.HongbaoInfo;

public class OrderQueryModule extends AbsModule {

	public OrderQueryInfo info;

	@Override
	public void parseData() throws Exception {
		try {

			backJson = (JSONArray) result;
			for (int i = 0; i < backJson.size(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("OrderQuery")) {
					parseOrderQuery(jsonObj.getJSONArray("DetailInfo"));
				} 

			}
		} catch (Exception e) {

			throw e;
		}

	}

	private void parseOrderQuery(JSONArray person) throws Exception {
		try {
			info = new OrderQueryInfo();
			List<OrderQueryItemInfo> list = new ArrayList<OrderQueryItemInfo>();
			for (int i = 0; i < person.size(); i++) {
				OrderQueryItemInfo info = new OrderQueryItemInfo();
				JSONObject obj = person.getJSONObject(i);
				info.setBetting(obj.getString(OrderQueryItemInfo.BETTIG));

				info.setIssueid(obj.getString(OrderQueryItemInfo.ISSUEID));
				info.setLotteryid(obj.getString(OrderQueryItemInfo.LOTTERYID));
				info.setOpennum(obj.getString(OrderQueryItemInfo.OPENNUM));

				info.setOrderpayRed(obj.getString("orderpayred"));

				info.setWinmoney(obj.getString(OrderQueryItemInfo.WINMONEY));
				info.setWinning(obj.getString(OrderQueryItemInfo.WINNING));
				info.setType(obj.getString(OrderQueryItemInfo.TYPE));
				info.setOrdertime(obj.getString(OrderQueryItemInfo.ORDERTIME));
				info.setCtime(obj.getString(OrderQueryItemInfo.CTIME));
				info.setIsaward(obj.getString(OrderQueryItemInfo.ISAWARD));
				info.setIssurepay(obj.getString(OrderQueryItemInfo.ISSUREPAY));
				info.setTradestatus(obj
						.getString(OrderQueryItemInfo.TRADESTATUS));
				info.setOuttime(obj.getString(OrderQueryItemInfo.OUTTIME));
				info.setPid(obj.getString(OrderQueryItemInfo.PID));
				info.setOrderpaymoney(obj.getString("orderpaymoney"));
				info.setStatus(obj.getString("status"));
				list.add(info);
				// money += Integer.valueOf(obj
				// .getString(OrderQueryItemInfo.WINMONEY));
				// info.setComb(obj.getString(OrderQueryItemInfo.COMB));
				// info.setIsaward(obj.getString(OrderQueryItemInfo.ISAWARD));
				info.setOrdertime(obj.getString(OrderQueryItemInfo.ORDERTIME));
				// info.setPid(obj.getString(OrderQueryItemInfo.PID));
				// info.setSedtime(obj.getString(OrderQueryItemInfo.SEDTIME));
				// info.setTradestatus(obj
				// .getString(OrderQueryItemInfo.TRADESTATUS));

			}
			info.setList(list);
		} catch (Exception e) {
			throw e;
		}

	}

	
}



